import { useEffect } from 'react';
import { useSelector } from 'react-redux';
import { Outlet } from 'react-router-dom';

import store from './reducers';
import { getUser, getUserProfits } from './reducers/user';

function App() {
  const login = useSelector((state: RootState) => state.user.login);

  useEffect(() => {
    store.dispatch(getUser());
  }, []);
  useEffect(() => {
    if (login) {
      store.dispatch(getUserProfits());
    }
  }, [login]);
  return <Outlet />;
}

export default App;
